Skip to content

Exclude observations at lat/long 0,0 from all loads and exports (#149) - #152

Merged
luandro merged 5 commits into
mainfrom
agent/comapeo-cloud-app/issue-149
Jul 27, 2026
Merged

Exclude observations at lat/long 0,0 from all loads and exports (#149)#152
luandro merged 5 commits into
mainfrom
agent/comapeo-cloud-app/issue-149

Conversation

@luandro

@luandro luandro commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves #149 — exclude observations located at the exact coordinate lat === 0 && lon === 0 from all data loads and exports. A 0,0 coordinate is the default/null island for GPS and represents missing location data, not a real observation; leaving it in produces spurious map points and export rows.

Approach

  • src/lib/coords.ts — adds a shared isZeroZeroCoord(lat, lon) predicate (extracts a 4× duplicated inline check).
  • src/lib/local-repositories.tsrepoGetObservations filters out 0,0 at the single read chokepoint that feeds both the list (data-layer.getObservations) and the map (getProjectPoints). getObservation (by-id) also returns undefined for a 0,0 record, consistent with it never being a valid observation.
  • src/lib/observation-export.tsobservationsToGeoJson and observationsToCsv filter 0,0 at the serialization boundary as defense-in-depth (the read filter already excludes them upstream).

Behavior notes

  • Only the exact 0,0 point is excluded. A real observation on the equator (lat: 0, lon: -60) or the prime meridian (lat: 45, lon: 0) is kept — verified by new regression tests.
  • Undefined / NaN coordinates are not dropped here; they are still caught by the pre-existing isValidCoord validation downstream, so no crash.
  • Deep links to a previously-0,0 observation now resolve to the observation detail screen's not-found state, since that record is no longer returned. This is accepted behavior for filtered-out records.

Tests

  • GeoJSON + CSV regression: single-zero equator/prime-meridian observations are retained.
  • Repository read: a seeded lat:0, lon:-60 observation is returned; only an exact 0,0 is excluded.
  • Two pre-existing 0,0 fixtures were repointed to real coordinates to prove the filter bites.

Verification

  • Full gate npm run validate (Husky pre-push hook): lint + coverage (2276 passed / 1 skipped) + production build + i18n check — green (PASSED).
  • Rebased onto current origin/main (no file conflicts).

Note: the repository's full-suite run is intermittently flaky on two unrelated test files — MapScreen.test.tsx (Save Map toggle) and AddArchiveServerDialog.test.tsx (invite redemption) — which fail only under the 180-file suite and pass 60/60 in isolation. They do not import the changed code. This PR does not modify them; the failing runs were flaky full-suite passes, not regressions.

github-actions Bot and others added 3 commits July 27, 2026 18:01
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add defense-in-depth 0,0 filtering in observationsToGeoJson and
observationsToCsv so the export serializers drop null-island
observations even if called with an unfiltered source list. Also guard
the by-id getObservation read for consistency with the read-layer
filter from #149.
Extract the duplicated !(lat === 0 && lon === 0) predicate into a single
isZeroZeroCoord helper in src/lib/coords.ts, replacing 4 inline copies
across local-repositories.ts (repoGetObservations filter + getObservation
guard) and observation-export.ts (observationsToGeoJson + observationsToCsv
filters).

Add regression tests asserting that real observations on the equator
(lat: 0, lon: -60) or prime meridian (lat: 45, lon: 0) are KEPT — only an
exact 0,0 is excluded. This guards against over-filtering that would drop
legitimate single-zero-coordinate observations.
greptile-apps[bot]

This comment was marked as off-topic.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Preview deployment ready: https://agent-comapeo-cloud-app-issu-p46s.comapeo-cloud-app.pages.dev

Commit: 5f50612

The plural repoGetObservations filter already excludes 0,0 from all
list/map/export reads, so the singular by-id guard was dead code with
zero production callers. It also introduced an 'exists but hidden'
contract (record in Dexie reported as not-found) with no test coverage,
conflicting with the repo's TDD cycle. Reverting keeps the single
source-of-truth filter and closes both pre-merge review nits.

Flagged by Kimi K3 via the production 'PR Review for Merge Readiness'
Langfuse prompt against PR #152.
@luandro
luandro merged commit 7e01946 into main Jul 27, 2026
21 checks passed
@luandro
luandro deleted the agent/comapeo-cloud-app/issue-149 branch July 27, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter out points at lat/long 0,0 from loading anywhere in the app

1 participant